import axios from "axios";

import type { ResponseData } from "./type";

enum API {
    GetTagArticle = "/article/tags",
    GetLastedArticle = "/article/lasted",
}

export interface ArticleData {
    date: string;
    source: string;
    tag: string;
    title: string;
}

export function getTagArticleData(tag : String) : Promise<any> {
    return axios.get<any, any>(API.GetTagArticle + "/" + tag);
}

export interface LastedArticleData extends ResponseData {
    data : ArticleData[];
}

export function getLastedArticle() : Promise<LastedArticleData> {
    return axios.get<any, LastedArticleData>(API.GetLastedArticle);
}